﻿package plugin.component
{
    import com.sh.game.display.*;
    import flash.display.*;
    import flash.utils.*;
    import morn.core.components.*;

    public class EffItem extends Sprite
    {
        private var img:Image;
        private var mc:XMLMovieClip;
        private var _timeID:uint = 0;
        private var oldparent:DisplayObjectContainer;
        private var _x:int = 0;
        private var _y:int = 0;
        private var isup:Boolean = false;
        public static var lightXml10:Class = EffItem_lightXml10;
        public static var lightXml1:Class = EffItem_lightXml1;
        public static var lightXml2:Class = EffItem_lightXml2;
        public static var lightXml3:Class = EffItem_lightXml3;
        public static var lightXml4:Class = EffItem_lightXml4;
        public static var lightXml5:Class = EffItem_lightXml5;
        public static var lightXml6:Class = EffItem_lightXml6;
        public static var lightXml7:Class = EffItem_lightXml7;
        public static var lightXml8:Class = EffItem_lightXml8;
        public static var lightXml9:Class = EffItem_lightXml9;
        public static var lightXml11:Class = EffItem_lightXml11;
        public static var lightXml12:Class = EffItem_lightXml12;
        public static var lightXml13:Class = EffItem_lightXml13;
        public static var lightXml14:Class = EffItem_lightXml14;
        public static var lightXml21:Class = EffItem_lightXml21;
        public static var lightXml22:Class = EffItem_lightXml22;
        public static var lightXml23:Class = EffItem_lightXml23;
        public static var lightXml24:Class = EffItem_lightXml24;
        public static var lightXml25:Class = EffItem_lightXml25;
        public static var lightXml26:Class = EffItem_lightXml26;
        public static var lightXml27:Class = EffItem_lightXml27;
        public static var lightXml28:Class = EffItem_lightXml28;
        public static var lightXml29:Class = EffItem_lightXml29;
        public static var lightXmlDic:Object = {10:lightXml10, 1:lightXml1, 2:lightXml2, 3:lightXml3, 4:lightXml4, 5:lightXml5, 6:lightXml6, 7:lightXml7, 8:lightXml8, 9:lightXml9, 11:lightXml11, 12:lightXml12, 13:lightXml13, 14:lightXml14, 21:lightXml21, 22:lightXml22, 23:lightXml23, 24:lightXml24, 25:lightXml25, 26:lightXml26, 27:lightXml27, 28:lightXml28, 29:lightXml29};

        public function EffItem()
        {
            this.img = new Image("png.tales.itemeff");
            this.addChild(this.img);
            this.img.blendMode = BlendMode.ADD;
            var _loc_1:* = new XML(new EffItem.lightXml10());
            this.mc = new XMLMovieClip(App.asset.getBitmapData("png.common.light"), _loc_1);
            this.addChild(this.mc);
            this.mc.x = 25;
            this.mc.y = 25;
            this.mc.scale = 0.6;
            this.mc.interval = 1000 / 8;
            this.mc.play();
            this.mc.blendMode = BlendMode.ADD;
            this.mouseChildren = false;
            this.mouseEnabled = false;
            return;
        }// end function

        public function hide() : void
        {
            if (this.parent)
            {
                this.parent.removeChild(this);
            }
            if (this._timeID > 0)
            {
                clearInterval(this._timeID);
                this._timeID = 0;
            }
            return;
        }// end function

        public function initadd(param1:DisplayObjectContainer, param2:int, param3:int) : void
        {
            this.oldparent = param1;
            this._x = param2;
            this._y = param3;
            this._timeID = setInterval(this.showlight, 200);
            return;
        }// end function

        public function show() : void
        {
            if (this.parent)
            {
                return;
            }
            this.oldparent.addChild(this);
            this.mc.play();
            this.x = this._x;
            this.y = this._y;
            this._timeID = setInterval(this.showlight, 200);
            return;
        }// end function

        private function showlight() : void
        {
            if (this.img.alpha <= 0.4)
            {
                this.img.alpha = 0.4;
                this.isup = true;
            }
            else if (this.img.alpha >= 1)
            {
                this.img.alpha = 1;
                this.isup = false;
            }
            if (this.isup)
            {
                this.img.alpha = this.img.alpha + 0.1;
            }
            else
            {
                this.img.alpha = this.img.alpha - 0.1;
            }
            return;
        }// end function

        public function dispose() : void
        {
            this.removeChild(this.img);
            this.removeChild(this.mc);
            if (this.oldparent)
            {
                this.oldparent.removeChild(this);
                this.oldparent = null;
            }
            if (this._timeID > 0)
            {
                clearInterval(this._timeID);
                this._timeID = 0;
            }
            return;
        }// end function

    }
}
